﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace QuanLyThuoc
{
    class NhanVien
    {
        const decimal luongcb = 2000000;
        string maNV;
        string hoTenNV;
        DateTime ngaySinh;
        string diaChi;
        string dienThoai;
        float heSoLuong;

        public string MaNV
        {
            get { return maNV; }
            set { maNV = value; }
        }
        public string HoTenNV
        {
            get { return hoTenNV; }
            set { hoTenNV = value; }
        }
        public DateTime NgaySinh
        {
            get { return ngaySinh; }
            set { ngaySinh = value; }
        }
        public string DiaChi
        {
            get { return diaChi; }
            set { diaChi = value; }
        }
        public string DienThoai
        {
            get { return dienThoai; }
            set { dienThoai = value; }
        }
        public float HeSoLuong
        {
            get { return heSoLuong; }
            set { heSoLuong = value; }
        }

        public NhanVien()
        { }

        public NhanVien(string maNV, string hoTenNV, DateTime ngaySinh, string diaChi, string dienThoai, float heSoLuong)
        {
            this.maNV = maNV;
            this.hoTenNV = hoTenNV;
            this.ngaySinh = ngaySinh;
            this.diaChi = diaChi;
            this.dienThoai = dienThoai;
            this.heSoLuong = heSoLuong;
        }

        public void NhapNV()
        {
            Console.Write("\nNhap ma nhan vien: ");
            maNV = Console.ReadLine();
            Console.Write("Nhap ho ten nhan vien: ");
            hoTenNV = Console.ReadLine();
            Console.Write("Nhap ngay sinh: ");
            ngaySinh = DateTime.Parse(Console.ReadLine());
            Console.Write("Nhap dia chi: ");
            diaChi = Console.ReadLine();
            Console.Write("Nhap so dien thoai: ");
            dienThoai = Console.ReadLine();
            Console.Write("Nhap he so luong: ");
            heSoLuong = float.Parse(Console.ReadLine());
        }

        private decimal tinhLuong()
        {
            decimal luong = (decimal)heSoLuong * luongcb;
            return luong;
        }

        public void XuatNV()
        {
            //Console.Write("Ma nhan vien: " + maNV + "\tHo ten: " + hoTenNV + "\tNgay sinh: " + ngaySinh + "\tDia chi: " + diaChi + "\tDien thoai: " + dienThoai + "\tHe so luong: " + heSoLuong);
            //Console.Write("\n\tMa nhan vien \tHo ten \tNgay sinh \tDia chi \tDien thoai \tHe so luong");
            Console.Write("" + maNV);
            Console.Write("\t" + hoTenNV);
            Console.Write("\t" + String.Format("{0:dd/MM/yyyy}", ngaySinh));
            Console.Write("\t" + diaChi);
            Console.Write("\t" + dienThoai);
            Console.Write("\t" + tinhLuong());
        }

        public void ghiFile()//lương???
        {
            FileStream file = new FileStream("DSNhanVien.txt", FileMode.Append);
            BinaryWriter br = new BinaryWriter(file);
            br.Write(maNV);
            br.Write(hoTenNV);
            br.Write(String.Format("{0:dd/MM/yyyy}", ngaySinh));
            br.Write(diaChi);
            br.Write(dienThoai);
            br.Write(heSoLuong.ToString());
            br.Close();
            file.Close();
        }
    }
}
